package com.ruoyi.od_organizer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.od_organizer.domain.OdActivityScore;
import com.ruoyi.od_organizer.service.IOdActivityScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价查看Controller
 * 
 * @author 榛子
 * @date 2023-06-30
 */
@RestController
@RequestMapping("/od_organizer/score")
public class OdActivityScoreController extends BaseController
{
    @Autowired
    private IOdActivityScoreService odActivityScoreService;

    /**
     * 查询评价查看列表
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdActivityScore odActivityScore)
    {
        startPage();
        List<OdActivityScore> list = odActivityScoreService.selectOdActivityScoreList(odActivityScore);
        return getDataTable(list);
    }

    /**
     * 导出评价查看列表
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:export')")
    @Log(title = "评价查看", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OdActivityScore odActivityScore)
    {
        List<OdActivityScore> list = odActivityScoreService.selectOdActivityScoreList(odActivityScore);
        ExcelUtil<OdActivityScore> util = new ExcelUtil<OdActivityScore>(OdActivityScore.class);
        util.exportExcel(response, list, "评价查看数据");
    }

    /**
     * 获取评价查看详细信息
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(odActivityScoreService.selectOdActivityScoreById(id));
    }

    /**
     * 新增评价查看
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:add')")
    @Log(title = "评价查看", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OdActivityScore odActivityScore)
    {
        return toAjax(odActivityScoreService.insertOdActivityScore(odActivityScore));
    }

    /**
     * 修改评价查看
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:edit')")
    @Log(title = "评价查看", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdActivityScore odActivityScore)
    {
        return toAjax(odActivityScoreService.updateOdActivityScore(odActivityScore));
    }

    /**
     * 删除评价查看
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:score:remove')")
    @Log(title = "评价查看", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(odActivityScoreService.deleteOdActivityScoreByIds(ids));
    }
}
